<?php
/**
 * Created by PhpStorm
 * author: bxm
 * Date: 2023/3/10
 * Time: 10:04
 */

namespace app\api\controller\evaluation;

use app\admin\model\EvaluationElist;
use app\admin\model\EvaluationQrcode;
use app\admin\model\EvaluationTemplate;
use app\common\controller\ApiController;
use think\App;

header('Access-Control-Allow-Origin:*');
ini_set("max_execution_time", 300);
class Qrcode extends  ApiController
{
    public function __construct(App $app)
    {
        parent::__construct($app);

        $this->model = new \app\admin\model\EvaluationQrcode();

    }

    public function getQrList($users_id)
    {
        $list = EvaluationQrcode::order('id','desc')->select();
        foreach ($list as $v){
            $v->template_name = EvaluationTemplate::where('id',$v->template_id)->value('name');
            $v->type = 1;//去评价
            $exist = EvaluationElist::where('qr_id',$v->id)->where('users_id',$users_id)->find();
            if(!empty($exist)){
                $v->type = 2;//去追评
            }
        }
        $res = array('code' => '0', 'msg' => '上传成功!', 'data' => $list);
        echo json_encode($res);
    }
}